<template>
  <div class="popout">
    <div class="pop-up">
      <header>
        <span>添加数据</span>
        <svg-icon
          icon-class="x"
          @click="addpop"
        />
      </header>
      <main>
        <el-form
          ref="form"
          :model="form"
          label-width="80px"
        >
          <el-form-item label="名称">
            <el-input
              v-model="form.name"
              placeholder="请输入名称"
            />
          </el-form-item>
          <el-form-item label="时间范围">
            <el-time-select
              v-model="startTime"
              placeholder="起始时间"
              start="08:30"
              step="00:15"
              end="18:30"
            />
            <el-time-select
              v-model="endTime"
              placeholder="结束时间"
              start="08:30"
              step="00:15"
              end="18:30"
              :min-time="startTime"
            />
          </el-form-item>
          <el-form-item label="幻灯片">
            <el-upload
              action="https://jsonplaceholder.typicode.com/posts/"
              list-type="picture-card"
              :on-preview="handlePictureCardPreview"
              :on-remove="handleRemove"
              class="upload"
            >
              <i class="el-icon-camera" />
            </el-upload>
            <el-dialog v-model="dialogVisible">
              <img
                width="100%"
                :src="dialogImageUrl"
                alt
              >
            </el-dialog>
          </el-form-item>
          <el-form-item label="状态">
            <el-switch
              v-model="value"
              active-color="#148eff"
              inactive-color="#ff4949"
            />
          </el-form-item>
          <el-form-item>
            <el-button
              type="primary"
              @click="onSubmit"
            >
              提交
            </el-button>
          </el-form-item>
        </el-form>
      </main>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      startTime: "",
      endTime: "",
      value: "",
      num: 1,
      dialogImageUrl: "",
      dialogVisible: false,
      form: {
        name: "",
        region: "",
        date1: "",
        date2: "",
        delivery: false,
        type: [],
        resource: "",
        desc: ""
      }
    };
  },
  methods: {
    handleChange(value) {
      console.log(value);
    },
    handleRemove(file, fileList) {
      console.log(file, fileList);
    },
    onSubmit() {
      this.$emit("isShowFlag", false);
    },
    addpop() {
      this.$emit("isShowFlag", false);
    },
    handlePictureCardPreview(file) {
      this.dialogImageUrl = file.url;
      this.dialogVisible = true;
    }
  }
};
</script>

<style lang="scss">
.popout {
  width: 100%;
  height: 100%;
  background: rgba($color: #000000, $alpha: 0.8);
  position: fixed;
  top: 0;
  left: 0;
  z-index: 9999;
  .pop-up {
    width: 540px;
    height: auto;
    background: #fff;
    margin: 150px auto;
    border-radius: 8px;
    padding: 9px;
    header {
      height: 31px;
      border-bottom: 1px solid #f6f7f8;
      display: flex;
      justify-content: space-between;
      align-items: center;
      span {
        color: #c2c4c7;
        font-weight: bold;
        font-size: 14px;
      }
    }
    main {
      margin-top: 9px;
      .el-upload--picture-card {
        width: 40px;
        height: 40px;
        line-height: 40px;
        text-align: center;
      }
      .el-upload--picture-card i {
        font-size: 14px;
      }
      .el-select {
        width: 100%;
      }
    }
  }
}
</style>
